Subscribe Us

Responsive Advertisement

Advertisement

1560C codeforces solution in cpp

 1560C codeforces solution in cpp

by ujjal roy


#include<bits/stdc++.h>

using namespace std;

main()

{

   int t,k,i,sr;

   cin>>t;

   while(t--)

   {

       int c=0;

       cin>>k;

       sr=sqrt(k);

       if(sr*sr==k) cout<<sr<<" "<<"1"<<endl;

       else

       {

           int v=sr*sr;

           for(i=1;i<=sr+1;i++)


           {       v++;


                if(v==k)

                {

                    cout<<i<<" "<<sr+1<<endl;

                    c=1;

                    break;

                }

           }

           if(c==0)

           {

            for(i=1;i<=sr;i++)

           {

                v++;

                if(v==k)

                {int r=((sr+1)*(sr+1))-v+1;

                    cout<<sr+1<<" "<<r<<endl;;

                    c=1;

                    break;

                }

           }

           }

       }

   }




    return 0;

}


Post a Comment

0 Comments